package tw.com.hitevision.whiteboard.android.stateFile;

import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;

import tw.com.hitevision.whiteboard.android.render.Autoshape;
import tw.com.hitevision.whiteboard.android.state.AutoshapeProperty;

public class AutoShapeStateFile extends BaseStateFile {
    private AutoshapeProperty.Type type;
    private boolean filled;
    private PointF endPoint;
    private PointF thirdPoint;
    private PointF fourthPoint;
    private PointF centerPoint;
    private float autoshapeDegree;
    private int pointCounter;
//    private RectF detectRectF;
//    private Rect detectRect;
//    private Region detectClipRegion;
    private float[] detectRectFValues;
    private int[] detectRectValues;
    private int[] detectClipRegionValues;
    private float[] arrowHeadLeft;
    private float[] arrowHeadRight;
    private PointF[] cornerPoint;
    private float[] points;

    public AutoShapeStateFile(Autoshape autoshape, boolean filled,
                              PointF endPoint, PointF thirdPoint, PointF fourthPoint, PointF centerPoint,
                              float autoshapeDegree, int pointCounter, RectF detectRectF, Rect detectRect, Region detectClipRegion,
                              float[] arrowHeadLeft, float[] arrowHeadRight, PointF[] cornerPoint) {
        super(autoshape);
        this.setClassName(Autoshape.class.getSimpleName());

        this.type = autoshape.getType();
        this.filled = filled;
        this.endPoint = new PointF(endPoint.x ,endPoint.y);
        this.thirdPoint = new PointF(thirdPoint.x ,thirdPoint.y);
        this.fourthPoint = new PointF(fourthPoint.x ,fourthPoint.y);
        this.centerPoint = new PointF(centerPoint.x ,centerPoint.y);
        this.autoshapeDegree = autoshapeDegree;
        this.pointCounter = pointCounter;
//        this.detectRectF = new RectF(detectRectF);
//        this.detectRect = new Rect(detectRect);
//        this.detectClipRegion = new Region(detectClipRegion);
        this.detectRectFValues = new float[]{detectRectF.left, detectRectF.top, detectRectF.right, detectRectF.bottom};
        this.detectRectValues = new int[]{detectRect.left, detectRect.top, detectRect.right, detectRect.bottom};
        Rect rect = detectClipRegion.getBounds();
        this.detectClipRegionValues = new int[]{rect.left, rect.top, rect.right, rect.bottom};
        this.arrowHeadLeft = arrowHeadLeft.clone();
        this.arrowHeadRight = arrowHeadRight.clone();
        this.cornerPoint = cornerPoint.clone();
        for (int i = 0; i < 4; i++) {
            this.cornerPoint[i].set(cornerPoint[i]);
        }
        this.points = autoshape.getPoints().clone();

    }

    public void setType(AutoshapeProperty.Type type) {
        this.type = type;
    }

    public AutoshapeProperty.Type getType() {
        return type;
    }

    public void setFilled(boolean filled) {
        this.filled = filled;
    }

    public boolean isFilled() {
        return filled;
    }

    public void setEndPoint(PointF endPoint) {
        this.endPoint = endPoint;
    }

    public PointF getEndPoint() {
        return endPoint;
    }

    public void setThirdPoint(PointF thirdPoint) {
        this.thirdPoint = thirdPoint;
    }

    public PointF getThirdPoint() {
        return thirdPoint;
    }

    public void setFourthPoint(PointF fourthPoint) {
        this.fourthPoint = fourthPoint;
    }

    public PointF getFourthPoint() {
        return fourthPoint;
    }

    public void setCenterPoint(PointF centerPoint) {
        this.centerPoint = centerPoint;
    }

    public PointF getCenterPoint() {
        return centerPoint;
    }

    public void setAutoshapeDegree(float degree) {
        this.autoshapeDegree = degree;
    }

    public float getAutoshapeDegree() {
        return autoshapeDegree;
    }

    public void setPointCounter(int pointCounter) {
        this.pointCounter = pointCounter;
    }

    public int getPointCounter() {
        return pointCounter;
    }

//    public void setDetectRectF(RectF detectRectF) {
//        this.detectRectF = detectRectF;
//    }
//
//    public RectF getDetectRectF() {
//        return detectRectF;
//    }
//
//    public void setDetectRect(Rect detectRect) {
//        this.detectRect = detectRect;
//    }
//
//    public Rect getDetectRect() {
//        return detectRect;
//    }
//
//    public void setDetectClipRegion(Region detectClipRegion) {
//        this.detectClipRegion = detectClipRegion;
//    }
//
//    public Region getDetectClipRegion() {
//        return detectClipRegion;
//    }

    public void setArrowHeadLeft(float[] arrowHeadLeft) {
        this.arrowHeadLeft = arrowHeadLeft;
    }

    public float[] getArrowHeadLeft() {
        return arrowHeadLeft;
    }

    public void setArrowHeadRight(float[] arrowHeadRight) {
        this.arrowHeadRight = arrowHeadRight;
    }

    public float[] getArrowHeadRight() {
        return arrowHeadRight;
    }

    public void setCornerPoint(PointF[] cornerPoint) {
        this.cornerPoint = cornerPoint;
    }

    public PointF[] getCornerPoint() {
        return cornerPoint;
    }

    public void setPoints(float[] points) {
        this.points = points;
    }

    public float[] getPoints() {
        return points;
    }

    public void setDetectRectFValues(float[] detectRectFValues) {
        this.detectRectFValues = detectRectFValues;
    }

    public float[] getDetectRectFValues() {
        return detectRectFValues;
    }

    public int[] getDetectRectValues() {
        return detectRectValues;
    }

    public void setDetectRectValues(int[] detectRectValues) {
        this.detectRectValues = detectRectValues;
    }

    public void setDetectClipRegionValues(int[] detectClipRegionValues) {
        this.detectClipRegionValues = detectClipRegionValues;
    }

    public int[] getDetectClipRegionValues() {
        return detectClipRegionValues;
    }
}
